<?php
/**
 * <pre>
 * DiabloStudios.Board v1.0
 * 
 * Functions used in Administration Panel
 * </pre>
 * 
 * @copyright	(c) 2010 DiabloStudios
 * @license		GNU Affero GPL v3 or newer
 * @package		PHP-Fusion
 * @subpackage	DiabloStudios.Board
 * @link		http://diablostudios.pl
 * @since 		version 1.0
 * @version     $Id: admin_functions.php 1 2011-03-20 11:56:30Z Bartek $
 * 
 */

/**
 * Show the box with errors
 * 
 * @param array The array of errors
 * @return string Formatted box with errors message
 */
function output_inline_error($errors)
{

	global $locale;
	if (!is_array($errors))
	{
		$errors = array($errors);
	}

	$er = "<div class='errors'>";
	$er .= "Wystąpiły następujące błędy:";
	$er .= "<ul>\n";
	foreach ($errors as $error)
	{
		$er .= "<li>{$error}</li>\n";
	}
	$er .= "</ul>\n</div>\n";
	return $er;
}
/**
 * Output a single error message.
 *
 * @param string The message to output.
 */
function output_error($error)
{
	echo "<div class=\"errors\">\n";
	echo "{$error}\n";
	echo "</div>\n";
}

/**
 * Output a Javascript based tab control on to the page.
 *
 * @param array Array of tabs in name => title format. Name should correspond to the name of a DIV containing the tab content.
 * @param string The ID to use for the tabs for if you run multiple instances of the tabbing control in one html page
 */
function output_tab_control($tabs = array(), $id = "default")
{

	add_to_head("<script type=\"text/javascript\">
        jQuery(document).ready(function($) {
            $(\"#{$id}-tabs\").idTabs();
        });</script>");
	echo "<ul class=\"tabs\" id=\"{$id}-tabs\">\n";
	$tab_count = count($tabs);
	$done = 1;
	foreach ($tabs as $anchor => $title)
	{
		$class = "";
		if ($tab_count == $done)
		{
			$class .= " last";
		}
		if ($done == 1)
		{
			$class .= " first";
		}
		echo "<li class=\"{$class}\"><a href=\"#{$id}-tab{$done}\" class=\"tbl-border\">{$title}</a></li>\n";
		++$done;
	}
	echo "</ul>\n<div class='clear'></div>\n";
}

?>